package android.demo.activity.tab;

import android.app.LocalActivityManager;
import android.content.Intent;
import android.demo.BaseActivity;
import android.demo.R;
import android.os.Bundle;
import android.widget.TabHost;

public class TabActivity extends BaseActivity {

	private LocalActivityManager mlam;
	
	
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.tab);  
		mlam = new LocalActivityManager(this, false); 
		// 获取TabHost对象  
		TabHost tabHost = (TabHost) findViewById(R.id.tabhost);  
		// 如果没有继承TabActivity时，通过该种方法加载启动tabHost  
		mlam.dispatchCreate(savedInstanceState);
		tabHost.setup(mlam);  
//		tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("第一个标签", getResources().getDrawable(R.drawable.icon)).setContent(R.id.view1));  
//		tabHost.addTab(tabHost.newTabSpec("tab3").setIndicator("第三个标签").setContent(R.id.view3));  
//		tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator("第二个标签").setContent(R.id.view2));  
		
		tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("第一个标签", getResources().getDrawable(R.drawable.icon)).setContent(new Intent(this, TabPage1Activity.class)));  
		tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator("第二个标签").setContent(new Intent(this, TabPage2Activity.class)));
		tabHost.addTab(tabHost.newTabSpec("tab3").setIndicator("第三个标签").setContent(new Intent(this, TabPage3Activity.class))); 
	}
	
	
	protected void onResume() {
		super.onResume();
		mlam.dispatchResume(); 
	}
	
	
	protected void onPause() {
		super.onPause();
		mlam.dispatchPause(isFinishing());
	}
}
